<template>
  <div >
    <el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="基本信息" name="0">
          <el-form ref="form" :model="form0" label-width="150px">
  <el-form-item label="名称">
    <el-input v-model="form0.appName"></el-input>
  </el-form-item>
  <el-form-item label="语言">
    <el-select v-model="form0.lang" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onConfigure(0)">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
  </el-form>
    </el-tab-pane>
     <el-tab-pane label="性能优化收集设置" name="1">
          <el-form ref="form" :model="form1" label-width="150px">

   
 <el-form-item label="关闭信息上报">
    <el-switch v-model="form2.delivery"></el-switch>
  </el-form-item>
  
    <el-form-item label="不上报测试环境">
    <el-switch v-model="form2.delivery"></el-switch>
  </el-form-item>
   <el-form-item label="何时上报信息">
    <el-checkbox-group v-model="form.type">
       <el-checkbox label="全部" name="type"></el-checkbox>
      <el-checkbox label="节点解析完毕" name="type"></el-checkbox>
      <el-checkbox label="资源加载完毕(除接口)" name="type"></el-checkbox>
      <el-checkbox label="资源加载完毕" name="type"></el-checkbox>
      <el-checkbox label="页面离开时" name="type"></el-checkbox>
       <el-checkbox label="页面加载后1分钟" name="type"></el-checkbox>
      <el-checkbox label="每隔1分钟收集一次" name="type"></el-checkbox>
      
     
    </el-checkbox-group>
  </el-form-item>
    <el-form-item label="上报设备">
    <el-checkbox-group v-model="form.type">
       <el-checkbox label="全部" name="type"></el-checkbox>
      <el-checkbox label="安卓" name="type"></el-checkbox>
      <el-checkbox label="IOS" name="type"></el-checkbox>
       <el-checkbox label="微信" name="type"></el-checkbox>
      <el-checkbox label="安卓微信" name="type"></el-checkbox>
      <el-checkbox label="IOS微信" name="type"></el-checkbox>   
      <el-checkbox label="移动端" name="type"></el-checkbox>
      <el-checkbox label="PC" name="type"></el-checkbox>
      <el-checkbox label="IE" name="type"></el-checkbox>
      <el-checkbox label="谷歌" name="type"></el-checkbox>
     
    </el-checkbox-group>
  </el-form-item>
   <el-form-item label="慢资源设置">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onConfigure(0)">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
  </el-form>
    </el-tab-pane>
    <el-tab-pane label="错误集设置" name="2">
        <el-form ref="form" :model="form2" label-width="150px">
  <el-form-item label="浏览器">
    <el-input v-model="form2.name"></el-input>
  </el-form-item>
  <el-form-item label="同样错误上报次数">
    <el-input v-model="form2.name"></el-input>
  </el-form-item>
  <el-form-item label="手机">
    <el-select v-model="form2.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="软件版本">
    <el-col :span="11">
      <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
    </el-col>
    <el-col class="line" :span="2">-</el-col>
    <el-col :span="11">
      <el-time-picker type="fixed-time" placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
    </el-col>
  </el-form-item>
  <el-form-item label="测试环境不上报">
    <el-switch v-model="form2.delivery"></el-switch>
  </el-form-item>
  <el-form-item label="活动性质">
    <el-checkbox-group v-model="form.type">
      <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
      <el-checkbox label="地推活动" name="type"></el-checkbox>
      <el-checkbox label="线下主题活动" name="type"></el-checkbox>
      <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
    </el-checkbox-group>
  </el-form-item>
  <el-form-item label="特殊资源">
    <el-radio-group v-model="form.resource">
      <el-radio label="线上品牌商赞助"></el-radio>
      <el-radio label="线下场地免费"></el-radio>
    </el-radio-group>
  </el-form-item>
  <el-form-item label="活动形式">
    <el-input type="textarea" v-model="form.desc"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onConfigure(0)">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
</el-form>

    </el-tab-pane>
    <el-tab-pane label="报警方式" name="3">
        <el-form ref="form" :model="form" label-width="150px">
  <el-form-item label="邮件">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item label="手机">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item label="微信">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onConfigure(0)">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
  </el-form>
  </el-tab-pane>
    <el-tab-pane label="报警规则" name="4">
        <el-form ref="form" :model="form" label-width="150px">
  <el-form-item label="同一个错误报警一次">
      <el-switch v-model="form2.delivery"></el-switch>
  </el-form-item>
  <el-form-item label="活动区域">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onConfigure(0)">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
  </el-form>
  </el-tab-pane>
    <el-tab-pane label="Source Map" name="5">
        <el-form ref="form" :model="form" label-width="150px">
  <el-form-item label="活动名称">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item label="活动区域">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  </el-form></el-tab-pane>
    <el-tab-pane label="成员列表" name="6">
        
        <el-table
      :data="[]"
      style="width: 100%">
      <el-table-column
        prop="date"
        label="ID"
        >
      </el-table-column>
      <el-table-column
        prop="name"
        label="昵称"
        >
      </el-table-column>
      <el-table-column
        prop="name"
        label="用户名"
        >
      </el-table-column>
    </el-table>
        </el-tab-pane>
    <el-tab-pane label="其他设置" name="7">
        <el-form ref="form" :model="form" label-width="150px">
  <el-form-item label="活动名称">
    <el-input v-model="form.name"></el-input>
  </el-form-item>
  <el-form-item label="活动区域">
    <el-select v-model="form.region" placeholder="请选择活动区域">
      <el-option label="区域一" value="shanghai"></el-option>
      <el-option label="区域二" value="beijing"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="onConfigure(0)">保存</el-button>
    <el-button>取消</el-button>
  </el-form-item>
  </el-form></el-tab-pane>
  </el-tabs>
  </div>
</template>

<script>
import { mapGetters,mapState, mapActions } from 'vuex'
import api from "../api";
export default {
  name: 'Setting',
  created(){
    // this.$nextTick(_=>{
        
    // }) 
    
  },
  computed:{
     ...mapGetters(['appKey'])
  },
  methods:{
      getApp(){
        // console.log('ss',localStorage.getItem('appKey'))
        api.getApp({
          appKey:this.appKey
        }).then((res)=>{          
          this.form0 = res.data.data[0];
        })
      },
      handleClick(){},
      onConfigure(index){
        // debugger;
        let data = this[`form${index}`];
       data.appKey =  localStorage.getItem('appKey');
           api.editAppInfo(this[`form${index}`]).then(()=>{
             
           })
      },
  },
  watch:{
    appKey(){
       this.getApp()
    }
  },
  data () {
    return {
      form:{},
      form0:{},
      form1:{},
      form2:{},
      form3:{},
      form4:{},
      form5:{},
      form6:{},
      form7:{},
      form8:{},
      activeName:'0', 
      msg: 'Welcome to Your Vue.js App'
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
